﻿using NUnit.Framework;

namespace DictionaryExt.Test {

    [TestFixture]
    public class SplitInPairWith2Sep {

        [Test]
        public void Middle2SepAnd1Value() {
            Assert.Throws<StringExt.PatternException>(Middle2SepAnd1ValueException);
        }
        static void Middle2SepAnd1ValueException() {
            const string s = "a==1";
            string[] result = StringExt.StringExt.SplitInPair(s, StringExt.StringExt.RemoveSurroundingBlanks.No);
            Assert.AreEqual("a", result[0]);
            Assert.AreEqual("1", result[1]);
            Assert.AreEqual(2, result.Length);
        }

        [Test]
        public void Middle2SepAnd2Value() {
            Assert.Throws<StringExt.PatternException>(Middle2SepAnd2ValueException);
        }
        static void Middle2SepAnd2ValueException() {
            const string s = "a=1=2";
            string[] result = StringExt.StringExt.SplitInPair(s, StringExt.StringExt.RemoveSurroundingBlanks.No);
            Assert.AreEqual("a", result[0]);
            Assert.AreEqual("1", result[1]);
            Assert.AreEqual("2", result[2]);
            Assert.AreEqual(3, result.Length);
        }

    }
}
